<template>

	<view class="confirm-content">
		<TopBar :indexflag="true" :combakflag="true" :lang="false" :bottom="true" title="确认订单"
			barstyle="background-color:rgba(0,0,0,0)"></TopBar>
		<view class="" :style="{direction:i18nLocale=='ug'?'rtl':''}">
			<!-- 选择购买方式 -->
			<view class="selecet-type card-style" v-if="0">
				<view :class="index==actype?'selecet-item active':'selecet-item'" v-for="(item,index) in selecetList"
					@click="selecetType(index)">
					<view class="title">{{$t(item.title)}}</view>
					<view class="sub-title">{{$t(item.sub_title)}}</view>
					<view class="price" :style="{color:index==0?'#45bc1b':'#f4464b'}"> <text
							style="font-size: 30rpx;">￥</text> {{item.price}}</view>
					<view class="selecet-top" v-if="index==actype"></view>
				</view>
			</view>

			<!-- 选择地址 -->

			<view class="selecet-address card-style">
				<!-- <view class="title" v-if="!actvaddress">{{$t('ActveAddress')}}</view> -->
				<view class="address-content" v-if="orderdata">
					<view class="title">
						<!-- {{i18nLocale=='ug'?orderdata.address.ug_name:item.community.cn_name}} -->
					</view>
					<view class="address">{{orderdata.address.detail}}</view>
					<view class="user">
						<text>{{orderdata.address.name}}</text>
						<view class="pone">{{orderdata.address.mobile}}</view>
					</view>
				</view>
				<u-icon name="arrow-right" color="#3f3f42" size="22" v-if="i18nLocale=='cn'"></u-icon>
				<u-icon name="arrow-left" color="#3f3f42" size="22" v-if="i18nLocale=='ug'"></u-icon>
			</view>
			<!-- 配送时间 -->

			<view class="selecet-time card-style">
				<view class="title">{{$t('DeliveryTime')}}</view>
				<view class="time">
					<text>{{$t('Approximately')}} {{newData}}</text>
					<!-- <u-icon name="arrow-right" color="#3f3f42" size="22"></u-icon> -->
				</view>
			</view>


			<!-- 购物车列表 -->

			<view class="cart-list card-style">
				<view class="cart-list ">
					<view class="card-item">
						<view class=""  v-for="(big_item,big_index) in orderdata.items" v-if="orderdata.items.length">
							<view class="item" v-for="(item,index) in big_item.content">
								<view class="left">
									<image :src="getImgSrc(item.img)" class="img"></image>
									<view class="shop-content">
										<view class="name">
											{{ i18nLocale=='ug'?item.ug_name:item.cn_name }}
										</view>
										<view class="qut"> <text class="x-text">X</text> <text>{{item.qty}}</text>
										</view>
									</view>
								</view>
								<view class="right">
									￥{{item.price}}
								</view>
							</view>
						</view>
					</view>
				</view>

				<view class="delivery-fees">
					<view class="title">{{$t('DeliveryFees')}}</view>
					<view class="price">￥ 3</view>
				</view>
				<view class="all-Price">
					<view class="title">{{$t('TotalPrice')}}</view>
					<view class="price">￥ {{orderdata.fee}}</view>
				</view>
			</view>

			<!-- 备注 -->
			<view class="remark">
				<view class="title">{{$t('Remark')}}</view>
				<u--textarea v-model="remark_value" disabled :placeholder="$t('RemarkPlaceholder')"
					border="none"></u--textarea>
			</view>

			<view class="bottom-button" :style="{direction:i18nLocale=='ug'?'ltr':''}">
				<view class="price">￥<text style="font-weight: bold;">{{orderdata.fee}}</text> </view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getaddressone,
		postorders,
		getorderone
	} from '@/api/all.js';
	export default {
		data() {
			return {
				actype: 0,
				selecetList: [{
						title: 'TakeawayDelivery',
						sub_title: 'TakeawayPlaceholder',
						price: '187'
					},
					{
						title: 'ArriveStore',
						sub_title: 'ArrivePlaceholder',
						price: '183'
					}
				],
				addressshow: false,
				timeshow: false,
				newData: new Date().getHours() + ':' + new Date().getMinutes(),
				actvaddress: '',
				remark_value: '',
				selecetItem: [],
				orderdata: ''
			}
		},
		onLoad(e) {
			if (e.id) {
				this.getorderOne(e.id);
			}
			uni.setNavigationBarTitle({
				title: this.$t('OrderDtadail')
			})
			//订单处理

		},
		computed: {
			price() {
				return this.$store.state.shop.totalprice;
			},
			totalnumber() {
				return this.$store.state.shop.totalnumber;
			},
			totalshop() {
				return this.$store.state.shop.totalshop;
			},

			i18nLocale() {
				return this.$i18n.locale;
			},

		},
		methods: {

			//获取地址
			getAddress(id) {
				let that=this;
				getaddressone({id:id}).then((res)=>{
					if(res.code==200){
						let data=res.body.data;
						that.actvaddress=data;
					}
				})
			},
			getorderOne(id) {
				let that = this;
				getorderone({
					id: id
				}).then((res) => {
					if (res.code == 200) {
						let data = res.body.data;
						this.getAddress(data.address_id);
						that.orderdata = data;
						console.log(data, '++++++')
					}

				})
			},

		}
	}
</script>

<style lang="scss" scopd>
	.confirm-content {
		width: 100%;
		padding: 20rpx 20rpx;
		box-sizing: border-box;
		padding-bottom: 200rpx;

		.selecet-type {
			.selecet-item {
				height: 200rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-around;
				width: 48%;
				border: 4rpx solid $uni-border-color;
				border-radius: $uni-border-radius-lg;
				box-sizing: border-box;
				padding: $uni-spacing-padding-sm;
				position: relative;
				overflow: hidden;

				.title {
					font-size: $uni-font-size-base;
				}

				.sub-title {
					color: $uni-text-color-grey;
					font-size: $uni-font-size-sm1;
					padding: 10rpx 0rpx;
				}

				.price {
					font-size: $uni-font-size-lg;
					font-weight: bold;
				}

				.selecet-top {
					&:before {
						content: '';
						position: absolute;
						right: 0;
						top: 0;
						border-top-right-radius: 10rpx;
						border: 40rpx solid $uni-color-topic;
						border-bottom-color: transparent;
						border-left-color: transparent;
					}

					&:after {
						content: '';
						width: 10rpx;
						height: 25rpx;
						position: absolute;
						right: 6rpx;
						top: 3rpx;
						border: 8rpx solid #fff;
						border-top-color: transparent;
						border-left-color: transparent;
						transform: rotate(35deg);
					}




				}
			}

			.active {
				border-color: $uni-color-topic;
			}
		}

		.selecet-address {
			.title {
				color: $uni-color-title;
				font-size: $uni-font-size-base;
			}

			.address-content {
				display: flex;
				flex-direction: column;

				.user {
					display: flex;
					padding-top: 20rpx;
					color: $uni-text-color-grey;

					.pone {
						padding: 0rpx 30rpx;
					}
				}
			}
		}

		.addres-liist {
			width: 100%;
			height: 70vh;
			position: relative;

			.top-title {
				width: 100%;
				height: 100rpx;
				font-size: $uni-font-size-lg;
				color: $uni-color-title;
				background-color: #eff1f6;
				border-radius: $uni-border-radius-lg 0rpx 0rpx;
				box-sizing: border-box;
				display: flex;
				justify-content: center;
				align-items: center;
			}

		}

		.selecet-time {
			color: $uni-color-title;
			font-size: $uni-font-size-base;

			.time {
				display: flex;
				align-items: center;


				text {
					padding: 0rpx $uni-spacing-padding-sm;
				}


			}
		}

		.cart-list {
			display: flex;
			flex-direction: column;
			width: 100%;

			.card-item {
				width: 100%;

			}

			.item {
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 15rpx;

				.left {
					display: flex;
					align-items: center;

					image {
						width: 120rpx;
						height: 100rpx;
						border-radius: $uni-border-radius-sm;
					}

					.shop-content {
						display: flex;
						flex-direction: column;
						justify-content: space-between;
						padding: 0rpx 20rpx;

						.name {
							font-weight: bold;
							padding: 10rpx 0rpx;
						}

						.qut {
							font-size: $uni-font-size-base;
							color: $uni-text-color-grey;

							.x-text {
								font-size: $uni-font-size-sm0;
								padding-right: 3rpx;
							}
						}
					}

				}

				.right {
					display: flex;
					align-items: center;
					color: $uni-color-topic;
				}
			}

			.delivery-fees {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 30rpx 0rpx;
				border-top: 2rpx solid $uni-border-color;
				border-bottom: 2rpx solid $uni-border-color;
				margin-top: 30rpx;

				.title {
					color: $uni-color-title;
					font-size: $uni-font-size-base;
				}

				.price {
					color: $uni-text-color-grey;
					direction: ltr !important;
				}
			}

			.all-Price {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: $uni-spacing-padding-sm 0rpx;

				.price {
					direction: ltr !important;
				}

				.title {
					color: $uni-color-title;
					font-size: $uni-font-size-base;
				}
			}
		}

		.remark {
			width: 100%;
			display: flex;
			flex-direction: column;
			background-color: $uni-bg-color-box;
			border-radius: $uni-border-radius-lg;
			padding: $uni-spacing-padding-sm;
			box-sizing: border-box;
			margin-top: 20rpx;
			box-shadow: $uni-bg-shadow;

			.title {
				color: $uni-color-title;
				font-size: $uni-font-size-base;
			}

		}



		.card-style {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: $uni-bg-color-box;
			border-radius: $uni-border-radius-lg;
			padding: $uni-spacing-padding-sm;
			box-sizing: border-box;
			margin-top: $uni-spacing-margin-sm;
			box-shadow: $uni-bg-shadow;
		}

		.bottom-button {
			width: 92%;
			height: 100rpx;
			left: 4%;
			position: fixed;
			bottom: 4%;
			display: flex;
			justify-content: center;
			align-items: center;
			border-radius: 50rpx;
			background-color: rgba(51, 51, 51, 1);

			.price {
				color: #fff;
				font-size: 36rpx;
				font-weight: 300;

			}

		}
	}

	.uni-textarea-compute,
	.uni-textarea-line,
	.uni-textarea-placeholder,
	.uni-textarea-textarea {
		font-size: 26rpx !important;
	}
</style>